package com.junzhiit.nengji.app.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.app.service.BankCardService;
import com.junzhiit.nengji.app.web.vo.BankCardMobilePhoneVO;
import com.junzhiit.nengji.app.web.vo.BankCardVO;
import com.junzhiit.nengji.app.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;


@RestController
@RequestMapping("/bank/card")
public class BankCardController extends BaseController{
	
	@Autowired
	private BankCardService bankCardService;

	@ApiOperation("查询该店铺所有银行卡")
	@RequestMapping(method = RequestMethod.GET)
	public ResultVO findAll(String sessionId) {
		return bankCardService.findAll(sessionId);
	}
	
	@ApiOperation(value="获取手机验证码")
	@RequestMapping(value = "/get/mobile/phone/code", method = RequestMethod.GET)
	public ResultVO getMobilePhoneCode(BankCardMobilePhoneVO bankCardVO){
		AssertUtil.notBlank(bankCardVO.getSessionId(), "sessionId is required.");
		AssertUtil.notBlank(bankCardVO.getBankCard(), "bank card is required.");
		AssertUtil.notBlank(bankCardVO.getMobilePhone(), "mobile phone is required.");
		return bankCardService.getMobilePhoneCode(bankCardVO);
	}
	
	@ApiOperation(value = "查询个人银行卡四要素是否一致")
	@RequestMapping(value="/check",method = RequestMethod.GET)
	public ResultVO check(BankCardVO bankCardVO) {
		AssertUtil.notBlank(bankCardVO.getSessionId(), "sessionId is required.");
		return bankCardService.check(bankCardVO);
	}
	
	@ApiOperation(value = "绑定银行卡")
	@RequestMapping(value="/add",method = RequestMethod.POST)
	public ResultVO add(BankCardVO bankCardVO) {
		AssertUtil.notBlank(bankCardVO.getSessionId(), "sessionId is required.");
		return bankCardService.add(bankCardVO);
	}
	
	@ApiOperation(value = "查询每日剩余的查询次数")
	@RequestMapping(value="/check/count",method = RequestMethod.GET)
	public ResultVO checkCount(String sessionId) {
		return bankCardService.checkCount(sessionId);
	}
	
	@ApiOperation(value = "解绑银行卡")
	@RequestMapping(value="/del",method = RequestMethod.PUT)
	public ResultVO del(String bankCardId) {
		return bankCardService.del(bankCardId);
	}
	
	@ApiOperation(value = "查询企业银行卡要素是否一致")
	@RequestMapping(value="/check/bank",method = RequestMethod.GET)
	public ResultVO checkCompanyBank(BankCardVO bankCardVO) {
		AssertUtil.notBlank(bankCardVO.getSessionId(), "sessionId is required.");
		return bankCardService.checkCompanyBank(bankCardVO);
	}
	
	@ApiOperation(value = "再次查询企业银行卡验证结果")
	@RequestMapping(value="/check/again",method = RequestMethod.GET)
	public ResultVO checkAgain(BankCardVO bankCardVO) {
		AssertUtil.notBlank(bankCardVO.getSessionId(), "sessionId is required.");
		return bankCardService.checkAgain(bankCardVO);
	}
}
